﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;


namespace Deployment.Data.UI.Dialogs
{
    /// <summary>
    /// Interaction logic for AbstractDialog.xaml
    /// </summary>
    public abstract partial class AbstractDialog : Window
    {
        public static readonly DependencyProperty ContentControlProperty =
            DependencyProperty.Register("ContentControl",
            typeof(AbstractDialogContentControl),
            typeof(AbstractDialog));

        

        public event DependencyPropertyChangedEventHandler PropertyChanged;
        protected void SetValueDp(DependencyProperty property, object value)
        {
            SetValue(property, value);
            if (PropertyChanged != null)
                PropertyChanged(this, new DependencyPropertyChangedEventArgs());
        }

        public AbstractDialogContentControl ContentControl
        {
            get { return (AbstractDialogContentControl)GetValue(ContentControlProperty); }
            set { SetValueDp(ContentControlProperty, value); }
        }


        public AbstractDialog(string title)
        {
            InitializeComponent();
            if (!string.IsNullOrEmpty(title))
                this.Title = title;
        }

        private void OkClicked(object sender, RoutedEventArgs e)
        {
            if (performOkAction())
                DialogResult = true;
        }

        protected abstract bool performOkAction();
    }
}
